package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.Map;

/**
 * @author dyqstart
 * @create 2021-09-03-14:58
 * @since 1.0.0
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    SupplierService supplierService;

    @PostMapping("/list")
    public Map<String,Object> getSupplierList(Integer page,Integer rows,String supplierName){

        Map<String,Object> map = supplierService.getSupplierList(page,rows,supplierName);

        return map;
    }

    @PostMapping("/save")
    public ServiceVO saveOrUpdateSupplierInfo(Supplier supplier,
                                              @PathParam("supplierId") Integer supplierId){
         supplierService.saveOrUpdateSupplierInfo(supplier,supplierId);
         return new ServiceVO(100,"请求成功",null);
    }

    @PostMapping("/delete")
    public ServiceVO deleteSupplier(@PathParam("ids") String ids){

        supplierService.deleteSupplier(ids);
        return new ServiceVO(100,"请求成功",null);
    }


}
